"""
7-5 最佳情侣身高差
"""


def resolution1():
    N = int(input())
    for _ in range(N):
        lines = input().split(" ")
        if lines[0] == 'F':
            print("%.2f" % (float(lines[1]) * 1.09))
        elif lines[0] == 'M':
            print("%.2f" % (float(lines[1]) / 1.09))
    pass


if __name__ == '__main__':
    resolution1()